import { ApiProperty, OmitType, PartialType } from '@nestjs/swagger';
import { IsArray, IsInt, IsString } from 'class-validator';

export class MenuDto {
  @IsInt()
  @ApiProperty({ type: Number, description: 'id' })
  readonly id: number;

  @IsInt()
  @ApiProperty({ type: Number, description: '父Id' })
  public parent_id: number;

  @IsString()
  @ApiProperty({ type: String, description: '菜单名称' })
  public title: string;

  @IsString()
  @ApiProperty({ type: String, description: '菜单路径' })
  public path: string;

  @IsString()
  @ApiProperty({ type: String, description: '组件名称' })
  public name: string;

  @IsString()
  @ApiProperty({ type: String, description: '组件' })
  public component: string;

  @IsString()
  @ApiProperty({ type: String, description: '是否外链(1是，0否)' })
  public is_frame: string;

  @IsString()
  @ApiProperty({ type: String, description: '菜单类型（M目录，C菜单，F按钮）' })
  public menu_type: string;

  @IsString()
  @ApiProperty({ type: String, description: '菜单显示状态' })
  public visible: string;

  @IsInt()
  @ApiProperty({ type: Number, description: '显示顺序' })
  public sort: number;

  @IsString()
  @ApiProperty({ type: String, description: '菜单状态（1正常，0停用）' })
  public status: string;

  @IsString()
  @ApiProperty({ type: String, description: '是否缓存（1缓存，0不缓存）' })
  public keep_alive: string;

  @IsString()
  @ApiProperty({ type: String, description: '权限标识' })
  public perms: string;

  @IsString()
  @ApiProperty({ type: String, description: '图标' })
  public icon: string;

  @IsString()
  @ApiProperty({
    type: String,
    description: '备注',
    default: null,
  })
  readonly remark: string;

  @ApiProperty({ type: Date, description: '创建时间', default: null })
  readonly created_date: Date;

  @IsString()
  @ApiProperty({
    type: String,
    description: '创建人',
    default: null,
  })
  readonly created_by: string;

  @ApiProperty({ type: Date, description: '更新时间', default: null })
  readonly updated_date: Date;

  @IsString()
  @ApiProperty({
    type: String,
    description: '更新人',
    default: null,
  })
  readonly updated_by: string;

  @IsArray()
  @ApiProperty({
    type: Array,
    description: '角色',
    default: [
      {
        id: 1,
      },
    ],
  })
  roles: any[];
}

export class CreateMenuDto extends PartialType(
  OmitType(MenuDto, ['id', 'created_date', 'updated_date']),
) {}

export class UpdateMenuDto extends PartialType(
  OmitType(MenuDto, ['created_date', 'updated_date']),
) {}
